<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>06_案例练习-冒泡排序</title>
    </head>
    <body>
        <script>
            var arr = [6,5,3,1,8,7,2,4];

            // 5 3 1 6 7 2 4 8
            // 让最大的数 放到数组的最后面

            for(var i = 0; i < arr.length; i++) {
                if(arr[i] > arr[i+1]) {
                    var temp = arr[i];
                    arr[i] = arr[i+1];
                    arr[i+1] = temp;
                }
            }

            console.log(arr);


        </script>
    </body>
</html>